import { gql } from '@apollo/client';

export const GET_CUSTOMERS_LIST = gql`
  query ListQuery($name: String, $address: String, $page: Int, $pageSize: Int) {
    customers(name: $name, address: $address, page: $page, pageSize: $pageSize) {
      code
      message
      data {
        id
        name
        age
        address
      }
      pageInfo {
        page
        pageSize
        total
        totalPages
      }
    }
  }
`;

export const GET_CUSTOMER_DETAIL = gql`
  query QueryCustomerDetail($id: String!) {
    customer(id: $id) {
      code
      message
      data {
        id
        name
        age
        address
        phone
        sex
        education
      }
    }
  }
`;

export const REMOVE_CUSTOMER = gql`
  mutation removeCustomer($id: String!) {
    removeCustomer(id: $id) {
      code
      message
      data
    }
  }
`;

export const UPDATE_CUSTOMER = gql`
  mutation updateCustomer(
    $id: String
    $name: String
    $sex: String
    $address: String
    $age: Int
    $phone: String
    $education: String
  ) {
    updateCustomer(
      id: $id
      name: $name
      sex: $sex
      address: $address
      age: $age
      phone: $phone
      education: $education
    ) {
      code
      message
      data
    }
  }
`;

export const SAVE_CUSTOMER = gql`
  mutation createCustomer(
    $name: String
    $sex: String
    $address: String
    $age: Int
    $phone: String
    $education: String
  ) {
    addCustomer(
      name: $name
      sex: $sex
      address: $address
      age: $age
      phone: $phone
      education: $education
    ) {
      code
      message
      data
    }
  }
`;
